package com.bls.productmall.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bls.productmall.entity.Product;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ProductMapper extends BaseMapper<Product> {

    // 分页查询
    @Select("SELECT id,title,price,create_time,update_time FROM product LIMIT #{start},#{size}")
    List<Product> getProductPage(@Param("start") int start, @Param("size")  int size);

    // 根据产品名来分页查询
    @Select("SELECT id,title,price,create_time,update_time FROM product WHERE title LIKE #{title} LIMIT #{start},#{size}")
    List<Product> getProductByTitle(@Param("title") String title, @Param("start") int start, @Param("size")  int size);
}
